import {Component, ViewChild} from '@angular/core';
import {GnJsonTableComponent, GnMessageService, GnModalContent} from "geminis-ng";
import {ActivatedRoute} from "@angular/router";
import {HttpClient} from "@angular/common/http";

@Component({
  selector: 'everydata-list',
  templateUrl: './list.component.html'
})
@GnModalContent({
  key: 'everydata-list',
  width: '80vw',
  // height: '75vh',
  top: '40px'
})
export class ListComponent {

  configUrl: string = '';

  @ViewChild(GnJsonTableComponent) table!: GnJsonTableComponent;

  constructor(route: ActivatedRoute,
              private messageService: GnMessageService,
              private http: HttpClient) {
    route.queryParams.subscribe(param => {
      this.configUrl = '/api/everydata/tables/' + param.tableId;
    });
  }

  configLoaded(): void {
    // this.http.get('/api/everydata/dataValue/' + this.collection + '/' + this.id)
    //   .subscribe((resp: any): void => {
    //       if (!resp) {
    //         resp = {};
    //       }
    //       Object.assign(resp, this.defaultValue);
    //       this.form.form.setValue(resp);
    //     },
    //     error => {
    //       this.messageService.error('获取数据失败');
    //     });
  }

}
